import os
from common.base import webdriver, By, sleep

driver = webdriver.Chrome()
driver.maximize_window()
url = 'file:///' + os.path.abspath('html') + '/frame.html'
driver.get(url)
# 切换到id为f1的frame页面
sleep(2)
driver.switch_to.frame('f1')
print(driver.find_element(By.ID, 'inner_h3').get_attribute('outerHTML'))
# 切换到id为f1的frame页面
sleep(2)
driver.switch_to.frame('f2')
print(driver.find_element(By.ID, 'p1').get_attribute('outerHTML'))
# 切换到父页面
sleep(2)
driver.switch_to.parent_frame()
print(driver.find_element(By.ID, 'inner_h3').get_attribute('outerHTML'))
# 切换到主页面
sleep(2)
driver.switch_to.default_content()
print(driver.find_element(By.CSS_SELECTOR, 'H3').get_attribute('outerHTML'))
driver.quit()
